<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/courier-login.css">

</head>
<body>
    <div class="blank blank-head">

    </div>
    <div class="logo-img">
        <img src="../img/logo.png" alt="">
    </div>
    <div class="blank">

    </div>
    <div class="login-text">
        瞬达快递员
    </div>
    <div class="blank">

    </div>
    <div class="input-phone">
        <input id="phone" class="inputInfo" style="border-bottom: 1px solid rgb(180, 177, 177);" placeholder="手机号" type="text">
        <input id="password" class="inputInfo" placeholder="密码" type="password">
    </div>
    <div class="blank">

    </div>
   
    <div class="login-button">
        <button id="btn" type="button">登录</button>
        <div class="blank">

        </div>
        <a class="a-btn a-left">立即注册</a>
        <div class="a-center">
            <a class="a-btn a-cen">找回密码</a>
            <a class="a-btn a-right">检查网络</a>
        </div>
    </div>
    <script src="../js/jquery-3.3.1.min.js"></script>
    <script src="../js-cookie/jquery.cookie.js"></script>
    <script src="../js/layer/layer.js"></script>
    <script src="../../configure.js"></script>
    <script>
        $("#btn").click(function(){
            let phone =  $('#phone').val();
            let password = $('#password').val();
            $.ajax({
                url: url + "/courier/courierLogin",
                dataType: "json",
                type: "post",
                data : {
                    courierPhone:phone,
                    courierPassword:password
                },
                success: function (data) {
                    layer.msg('正在登录');
                    if(1 == data.code){
                        console.log(data)
                        // $.cookie('the_cookie'); // 读取 cookie
                        // $.cookie('the_cookie', 'the_value'); // 存储 cookie
                        // $.cookie('the_cookie', 'the_value', { expires: 7 }); // 存储一个带7天期限的 cookie
                        // $.cookie('the_cookie', '', { expires: -1 }); // 删除 cookie
                        $.cookie('courierId',data.data.id ); // 存储 cookie
                        $.cookie('courierX',data.data.reservedFields1 ); // 存储 cookie
                        $.cookie('courierY',data.data.reservedFields2); // 存储 cookie

                        layer.msg('登录成功', {icon: 1});
                        window.location.href = "courierHomePage.html";
                    }else if(2 == data.code){
                        layer.msg('登录失败', {icon: 1});

                    }
                }
            }, "json")
           
        })
    </script>
</body>
</html>